package info.xiaolong.exampleservice.service.serviceImpl;

import com.example.esplugins.utils.EsUtils;
import info.xiaolong.exampleservice.model.document.EsTestDoc;
import info.xiaolong.exampleservice.service.IEsTestService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * @Classname EsTestServiceImpl
 * @Description TODO
 * @Date 2022/4/27 13:46
 * @Created by Qinger
 */
@Service
@Slf4j
public class EsTestServiceImpl implements IEsTestService {

    @Resource
    private EsUtils esUtils;

    @Override
    public Boolean createIndex(String index) throws IOException {
        return esUtils.createIndex(index);
    }

    @Override
    public Boolean deleteIndex(String index) throws IOException {
        return esUtils.deleteIndex(index);
    }

    @Override
    public Boolean save(EsTestDoc doc, String index) throws IOException {
        return esUtils.save(doc, index, doc.getId());
    }

    @Override
    public Boolean saveAuto(EsTestDoc doc, String index) throws IOException {
        return esUtils.save(doc, index);
    }

    @Override
    public Boolean updateDoc(EsTestDoc doc, String index) throws IOException {
        return esUtils.updateDoc(doc, index, doc.getId());
    }
    @Override
    public Boolean deleteDoc(String id, String index) throws IOException {
        return esUtils.deleteDoc(id, index);
    }

    @Override
    public Map<String, Object> getById(String index, String id) throws IOException {
        return esUtils.getById(index, id);
    }

    @Override
    public Object getById4Class(String index, String id) throws IOException {
        return esUtils.getById(index, id, EsTestDoc.class);
    }

    @Override
    public Boolean ifDocExists(String index, String id) throws IOException {
        return esUtils.ifDocExists(index,id);
    }

    @Override
    public Boolean batchSaveDoc(String index, List<EsTestDoc> list) throws IOException {
        return esUtils.batchSaveDoc(index,list);
    }




}
